#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    socket = new QUdpSocket(this);

    socket->bind(QHostAddress::AnyIPv4,8877);

    connect(socket,&QUdpSocket::readyRead,this,&MainWindow::sock_read);

}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::sock_read()
{
    QByteArray array;
    QHostAddress address;
    quint16 port;
    array.resize(socket->bytesAvailable());
    socket->readDatagram(array.data(),array.size(),&address,&port);
    ui->textEdit->setText(tr(array));
}
